package com.keldian.mobilesafe.recevier;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
import android.telephony.SmsManager;
import android.util.Log;
import android.widget.Toast;

import com.keldian.mobilesafe.activity.Setup2Activity;
import com.keldian.mobilesafe.utils.SharePrefenceTool;

/**
 * Created by Administrator on 15-12-16.
 */
public class BootCompleteRecevier extends BroadcastReceiver {

    private TelephonyManager tm;


    @Override
    public void onReceive(Context context, Intent intent) {
        String saveSim = SharePrefenceTool.getSim(context);
        boolean protecting = SharePrefenceTool.getProtecting(context);
        if (protecting) {

            tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

            String realSim = tm.getSimSerialNumber() + "af";

            if (saveSim.equals(realSim)) {
                Toast.makeText(context, "sim_same", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(context, "sim_Change!", Toast.LENGTH_SHORT).show();
                SmsManager.getDefault().sendTextMessage(SharePrefenceTool.getSafeMobile(context),
                        null, "sim changing....", null, null);
                Log.d("BootCompleteRecevier", "发送短信");
            }
        }

    }
}
